<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News extends MY_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('News_model', 'news');
        /*$login_status  = $this->check_login_status();
        if (empty($login_status)){
            redirect('/');die;
        }*/
	}
    public function index()
    {
        $_SESSION['sidebar'] = "news";  
        $total_rows = $this->news->getMyNewsListCnt();
        $base_url = '/news/index?';
        $newsList = $this->news->getMyNewsList(" * ",0, 20);
        $data = array(
            'newsList'=>$newsList,
            );
        $this->load->view("news/index", $data);
    }

    public function more()
    {
        $_SESSION['sidebar'] = "news";  
        $per_page = $this->input->get('per_page') ? $this->input->get('per_page') : 0;
        $limit = 20;
        $total_rows = $this->news->getMyNewsListCnt();
        $base_url = '/news/index?';
        $page_links = $this->create_page_links($base_url,$total_rows,$limit);
        $newsList = $this->news->getMyNewsList(" * ",$per_page, $limit);
        $data = array(
            'newsList'=>$newsList,
            'page_links'=>$page_links,
            'per_page'=>$per_page,
            );
        $this->load->view("news/index_more", $data);
    }

    public function detail(){
        $_SESSION['sidebar'] = "news";
        $id = $this->input->get('id') ? $this->input->get('id') : 0;
        $fields = " * ";
        $detail = $this->news->getDetail($fields, $id);
        $this->load->view("news/detail", ['detail'=>$detail]);        
    }
    public function xiangqing(){
        $_SESSION['sidebar'] = "news";
        $id = $this->input->get('id') ? $this->input->get('id') : 0;
        $fields = " * ";
        $detail = $this->news->getDetail($fields, $id);
        $this->load->view("news/detail_nostyle", ['detail'=>$detail]);        
    }


	
}
/* End of file Index.php */
/* Location: ./application/controllers/news.php */
